<script lang="ts" setup>
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { SystemDeptExternalApi } from '#/api/system/deptexternal';

import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { getDeptExternalPage } from '#/api/system/deptexternal';

import { useExternalDetailGridColumns } from '../data';

const props = defineProps<{
  schoolId?: string;
}>();

const [GridExt, gridExtApi] = useVbenVxeGrid({
  gridOptions: {
    id: 'DeptExternal-grid-school',
    columns: useExternalDetailGridColumns(),
    height: '300px',
    pagerConfig: {
      enabled: true,
    },
    keepSource: true,
    proxyConfig: {
      ajax: {
        query: async ({ page }, formValues) => {
          return await getDeptExternalPage(
            {
              pageNo: page.currentPage,
              pageSize: page.pageSize,
              ...formValues,
              orgId: props.schoolId,
            },
            false,
            false,
          );
        },
      },
    },
    rowConfig: {
      keyField: 'id',
      isHover: true,
    },
    toolbarConfig: {
      refresh: true,
      search: true,
    },
  } as VxeTableGridOptions<SystemDeptExternalApi.DeptExternal>,
});
</script>

<template>
  <GridExt table-title="与其他系统关系" />
</template>
